This page last changed on Jan 03, 2012 by jed.wheeler@involver.com.

If logic provides a way that you can show different versions of entire feature blocks based on user location.  This is easy in SML by checking the current_locale, current_country, and current_language Global Context Variables.  

The complete set of country-language pairs for current_locale (facebooks built-in localization) is listed at ?facebook locale support and works based off the user's settings in facebook.  The additional current_country and current_language variables provided in SML allow you to localize based on user's country and language preferences independently.  

{% if current_locale == "en_UK" %}
  Hello, Mate!
{% elsif current_locale == "en_US" %}
  Hello!
{% elsif current_locale == "es_LA" %}
  Hola Amigo!
{% endif %}

The biggest problem with this is that previewing your code can be tricky during development.  There are two easy solutions.  First, at the bottom-left of your Facebook page, there is a copyright notice followed by a link stating your current language setting.  If you click that link, you can change your language setting, and see what things will look like for another language.

Alternately, you can use partials to ease this process.  For example,

{% partial name:'en_US'%}
  Hello, US english speaker
{% endpartial %}
{% partial name:'es_SP'%}
  Hola!
{% endpartial %}

{% current_locale == "en_US" %}
  {% render partial:'en_US' %}
{% elsif current_locale == "es_SP" %}
  {% render partial:'es_SP' %}
{% else %}
  No localized version...
{% endif %}

In the above style, you can easily comment out portions of the if block and explicitly call render for whichever locale's partial you are working on at that time.

Document generated by Confluence on Feb 12, 2013 09:09